From: Florian Müllner Date: Tue, 12 Feb 2019 14:16:08 +0000 (+0100) Subject: extensionPrefs: Avoid awkward indentation in string literal X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~845^2^2~83 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=95b80eec01edec6a18e22288095021f8fb9da5c2;p=gnome-shell.git extensionPrefs: Avoid awkward indentation in string literal The current code is carefully avoiding an overly wide line length as well as adding literal new lines to the string due to indentation. It's clever and barely legible. Instead, use one string per line similar to how they appear in the actual output, and join them together when setting the clipboard text. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608 --- diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js index b0be67f49..af1ad08d5 100644 --- a/js/extensionPrefs/main.js +++ b/js/extensionPrefs/main.js @@ -168,13 +168,20 @@ var Application = class { copyButton.connect('clicked', w => { let clipboard = Gtk.Clipboard.get_default(w.get_display()); - let backticks = '```'; - clipboard.set_text( - // markdown for pasting in gitlab issues - `The settings of extension ${extension.uuid} had an error:\n${ - backticks}\n${exc}\n${backticks}\n\nStack trace:\n${ - backticks}\n${exc.stack}${backticks}\n`, -1 - ); + // markdown for pasting in gitlab issues + let lines = [ + `The settings of extension ${extension.uuid} had an error:`, + '```', + `${exc}`, + '```', + '', + 'Stack trace:', + '```', + exc.stack.replace(/\n$/, ''), // stack without trailing newline + '```', + '' + ]; + clipboard.set_text(lines.join('\n'), -1); }); let spacing = new Gtk.SeparatorToolItem({ draw: false });